﻿using System;
using WhatCatch.Core;

namespace WhatCatch.Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            ////博客园
            //string url = "https://www.cnblogs.com/";
            //CrawlerConfig config = new CrawlerConfig();
            //config.TaskThreadNum = 1;
            //config.DetailTaskThreadNum = 3;
            //config.ListItemXPath = "//div[@id='post_list']/div[@class='post_item']";
            //config.PageItemXPath = "//div[@class='pager']/a";
            //config.DetailXPath = "";

            //模拟测试站点
            string url = "http://www.test.com/page/1";
            CrawlerConfig config = new CrawlerConfig();
            config.TaskThreadNum = 1;
            config.DetailTaskThreadNum = 3;
            config.ListItemXPath = "//div[@class='list']/div[@class='list-li']";
            config.PageItemXPath = "//div[@class='page']/a";
            config.DetailXPath = "";


            CrawlerService crawlerService = new CrawlerService(url, config);
            crawlerService.SetHttpHandler(new TestHttpHandler());
            crawlerService.Start();

            Console.Read();

            //Console.WriteLine("Hello World!");
        }
    }
}
